package com.qk.mapper;

import com.qk.pojo.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoleMapper {

    /**
     * 新增角色
     * @param role
     */
    @Insert("insert into role (name, label, remark, create_time, update_time) values (#{name}, #{label}, #{remark}, #{createTime}, #{updateTime})")
    void insert(Role role);

    /**
     * 列表查询
     * @param name
     * @param label
     * @return
     */

    List<Role> selectByLabel(String name, String label);

    /**
     * 删除角色
     * @param id
     */
    @Delete("delete from role where id = #{id} ")
    void deleteById(Integer id);

    /**
     * 修改角色
     * @param role
     */
    void updateById(Role role);

    /**
     * 根据ID查询角色
     * @param id
     * @return
     */
    @Select("select id, name, label, remark, create_time, update_time from role where id = #{id}")
    Role selectById(Integer id);

    /**
     *查询所有角色
     * @return
     */
    @Select("select id, name, label, remark, create_time, update_time from role order by update_time desc ")
    List<Role> findAll();
}
